package com.kaoshi.management.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.kaoshi.management.pojo.XtSettingsDrug;
import com.kaoshi.management.mapper.XtSettingsDrugMapper;
import com.kaoshi.management.service.XtSettingsDrugService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author author
 * @since 2024-10-30
 */
@Service
public class XtSettingsDrugServiceImpl extends ServiceImpl<XtSettingsDrugMapper, XtSettingsDrug> implements XtSettingsDrugService {

    @Override
    public Page<XtSettingsDrug> findAll(Integer current, Integer pageSize, XtSettingsDrug settingsDrug) {
        Page<XtSettingsDrug> page = new Page<>(current, pageSize);

        LambdaQueryWrapper<XtSettingsDrug> wrapper = new LambdaQueryWrapper<>();

        // 模糊查询
        if (settingsDrug.getTitle() != null) {
            wrapper.like(XtSettingsDrug::getTitle,settingsDrug.getTitle());
        }

        // 区间查询，可以根据需要添加其他字段
        if (settingsDrug.getStartDate() != null && settingsDrug.getEndDate() != null) {
            // 假设 XtSettingsInformationManagement 有一个获取日期的方法 getDate()
            wrapper.between(XtSettingsDrug::getOperationTime, settingsDrug.getStartDate(), settingsDrug.getEndDate());
        }

        return baseMapper.selectPage(page, wrapper);
    }
}
